package com.ucware.wimm;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.logging.LogRecord;
import java.util.logging.SimpleFormatter;

public class VerySimpleFormatter extends SimpleFormatter
{
    public static final String lineSeparator = System.getProperty("line.separator");

    /**
     * Format the given LogRecord. No date-time and logger class name added. 
     * @see java.util.logging.SimpleFormatter#format(java.util.logging.LogRecord)
     */
    public synchronized String format(LogRecord record)
    {
        final StringBuffer sb = new StringBuffer();

        sb.append(record.getLevel().getLocalizedName());
        sb.append(": ");
        sb.append(formatMessage(record));
        sb.append(lineSeparator);

        final Throwable throwable = record.getThrown();
        if (throwable != null) {
            try {
                final StringWriter sw = new StringWriter();
                final PrintWriter pw = new PrintWriter(sw);
                throwable.printStackTrace(pw);
                pw.close();
                sb.append(sw.toString());
            }
            catch (Exception ex) {}
        }
        return sb.toString();
    }
}
